<?php
namespace information\service;

/**--tmpl-use--**/
use herosphp\core\Loader;

class AdPlaceService extends CommonService{

    private $adminManagerDao = null;

    public function __construct($adPlaceModel,$adminManager) {
        $this->setModelDao(Loader::model($adPlaceModel));
        $this->adminManagerDao = Loader::model($adminManager);
    }
    public function getItems($conditions, $fields, $order, $limit, $group, $having)
    {
        $items = parent::getItems($conditions, $fields, $order, $limit, $group, $having); // TODO: Change the autogenerated stub
        if(!$items) return;
        $admin_condi = array();
        foreach($items as $item)
        {
            $admin_condi[] = $item['manager_id'];
        }
        $admins = $this->adminManagerDao->getItems(array('id'=>array('$in'=>$admin_condi)));
        foreach($items as $key=>$item)
        {
            foreach($admins as $admin)
            {
                if($item['manager_id']==$admin['id'])
                {
                    $items[$key]["manager_name"] = $admin['name'];
                }
            }
        }
        return $items;
    }
}

